package
{
	import flash.utils.describeType;
	
	import mx.utils.StringUtil;
	
	[Bindable]
	public class Kid
	{
		public var num:Number;
		public var fees:Number;
		public var fname:String="";
		public var lname:String="";
		public var dob:String="";
		public var grade:String="";
		public var sex:String="";
		public var shirtSize:String="";
		
		public function Kid(num:Number=0, fees:Number=0, fname:String=null, lname:String=null, dob:String=null, grade:String=null, sex:String=null, shirtSize:String=null) {
			this.num=num;
			this.fees=fees;
			this.fname=fname;
			this.lname=lname;
			this.dob=dob;
			this.grade=grade;
			this.sex=sex;
			this.shirtSize=shirtSize;
		}
		
		public function isAllEmpty():Boolean {
			return	StringUtil.trim(fname).length == 0
				&&	StringUtil.trim(lname).length == 0
				&&	StringUtil.trim(dob).length == 0
				&&	StringUtil.trim(grade).length == 0				 
				&&	StringUtil.trim(sex).length == 0
				&&	StringUtil.trim(shirtSize).length == 0;
		}
		
		public function isAllNotEmpty():Boolean {
			// make sure all fields are fields have a value
			return	fname != null 
				&&	fname.length > 0
				&&	lname != null 
				&&	lname.length > 0 
				&&	dob != null 
				&&	dob.length > 0 
				&&	grade != null				 
				&&	grade.length > 0
				&&	sex != null 
				&&	sex.length > 0
				&&	shirtSize != null 
				&&	shirtSize.length > 0;
		}
		
		public function clear():void {
            var classInfo:XML = describeType(this);
            for each (var v:XML in classInfo..accessor) {
                if ( v.@type == "String" ) {
                	this[v.@name]="";
                }
                if ( v.@type == "Date" ) {
                	this[v.@name]=null;
                } 
            }
		}
		
	}
}